package com.example.config;

import com.example.entity.Person;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;

/**
 * 根据条件判断进行的注入演示
 * Configuration如果放在类上，满足条件才对类中注册的bean进行注册
 */
@Configuration
@Conditional(WindowsCondition.class)
public class SpringConfig2 {

    @Bean("bill")
    @Conditional(WindowsCondition.class)
    public Person person1() {
        return new Person(1, "bill");
    }

    @Bean("jobs")
    @Conditional(MacCondition.class)
    public Person person2() {
        return new Person(2, "jobs");
    }

}



